package menu;

import base.Main;
import java.util.Collection;
import java.util.LinkedList;
import objects.DataObject;
import objects.GruObject;

public abstract class ObjectListMenuItem extends MenuItem {
	
	public ObjectListMenuItem( String caption ) {
		super( caption );
	}
	
	@Override
	public void select() {
		LinkedList<MenuItem> list = new LinkedList<MenuItem>();
		for( DataObject obj : getItems() ) {
			MenuItem item = new AddToSlotMenuItem( obj.toGruObject().getField( nameField ).toString(), obj.toGruObject(), this );
			item.object = obj.toGruObject();
			list.add( item );
		}
		Main.showMenu( list );
	}
	
	public abstract  Collection<DataObject> getItems();
	
	public abstract void selectItem( GruObject obj );
}
